package com.linkage.jz.bankruptcy.widget;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import com.linkage.jz.bankruptcy.R;

public class CreateZQUserNoticeDialog extends Dialog {

	/**
	 * 上下文对象 *
	 */
	Activity context;

	private Button btn_save_zq_u,btn_chancel_zq_u;

	public EditText text_name_zq_u,text_mobile_zq_u;
	public String mUsername ,mPhone,mNotifyType;
	public TextView tv_notice;
	public CheckBox ck_inmsg,ck_msg,ck_outmsg;




	private View.OnClickListener mClickListener;

	public CreateZQUserNoticeDialog(Activity context) {
		super(context);
		this.context = context;
	}

	public CreateZQUserNoticeDialog(Activity context, View.OnClickListener clickListener,String name,String phone) {
		super(context);
		this.context = context;
		this.mClickListener = clickListener;
		mUsername = name;
		mPhone = phone;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 指定布局
		this.setContentView(R.layout.create_zq_user_notice_dialog);



		/*
		 * 获取圣诞框的窗口对象及参数对象以修改对话框的布局设置, 可以直接调用getWindow(),表示获得这个Activity的Window
		 * 对象,这样这可以以同样的方式改变这个Activity的属性.
		 */
		Window dialogWindow = this.getWindow();

		WindowManager m = context.getWindowManager();
		Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
		WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
		// p.height = (int) (d.getHeight() * 0.6); // 高度设置为屏幕的0.6
		p.width = (int) (d.getWidth() * 0.95); // 宽度设置为屏幕的0.8
		dialogWindow.setAttributes(p);

		// 根据id在布局中找到控件对象

		ck_inmsg = (CheckBox) findViewById(R.id.ck_inmsg);
		ck_msg = (CheckBox) findViewById(R.id.ck_msg);
		ck_outmsg = (CheckBox) findViewById(R.id.ck_outmsg);
		tv_notice = (TextView)findViewById(R.id.tv_notice);
		if(!"".equalsIgnoreCase(mPhone))
		{
			ck_inmsg.setChecked(true);
			ck_msg.setChecked(true);
			ck_outmsg.setChecked(false);
			ck_outmsg.setClickable(false);
			ck_inmsg.setClickable(false);
			tv_notice.setVisibility(View.INVISIBLE);
		}else{
			ck_inmsg.setChecked(false);
//			ck_msg.setChecked(false);
			ck_outmsg.setChecked(true);
			ck_inmsg.setClickable(false);
			ck_msg.setClickable(false);
			ck_outmsg.setClickable(false);
			tv_notice.setVisibility(View.VISIBLE);
		}



		btn_save_zq_u = (Button) findViewById(R.id.btn_save_zq_u);

		btn_chancel_zq_u = (Button)findViewById(R.id.btn_chancel_zq_u);
		// 为按钮绑定点击事件监听器
		btn_save_zq_u.setOnClickListener(mClickListener);
		btn_chancel_zq_u.setOnClickListener(mClickListener);

		this.setCancelable(true);
	}
}


